//
//  String+Extension.swift
//  SinaWB_XY
//
//  Created by 小熊猫 on 15/10/17.
//  Copyright © 2015年 小熊猫. All rights reserved.
//

import Foundation
import UIKit

extension String{
    
    func size(font:UIFont,constrainedToSize:CGSize = CGSizeZero) -> CGSize{
        //将调用者转换成NSString
        let string = self as NSString
        
        //设置字体属性
        let attr = [
            NSFontAttributeName:font
        ]
        
      return  string.boundingRectWithSize(constrainedToSize, options: [NSStringDrawingOptions.UsesLineFragmentOrigin], attributes: attr, context: nil).size
        
    }
    
    
    
}